import java.util.Stack;

public class L232 {

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.push(1);
        myQueue.push(2);

        myQueue.peek();

        System.out.println(myQueue.pop());
        System.out.println(myQueue.empty());
    }

    static class MyQueue {
        int value;
        Stack<Integer> up = new Stack<Integer>();
        Stack<Integer> down = new Stack<Integer>();

        public MyQueue() {

        }

        public MyQueue(int value) {
            this.value = value;
        }

        public MyQueue(int value, Stack<Integer> up, Stack<Integer> down) {
            this.value = value;
            this.up = up;
            this.down = down;
        }

        public void push(int x) {
            up.push(x);

        }

        public int pop() {
            deal();
            return down.pop();
        }

        public int peek() {
            deal();
            return down.peek();
        }

        private void deal() {
            if (down.isEmpty()) {
                while (!up.isEmpty()) {
                    down.push(up.pop());
                }
            }
        }

        public boolean empty() {
            return up.isEmpty() && down.isEmpty();
        }
    }

/**
 * Your MyQueue object will be instantiated and called as such:
 * MyQueue obj = new MyQueue();
 * obj.push(x);
 * int param_2 = obj.pop();
 * int param_3 = obj.peek();
 * boolean param_4 = obj.empty();
 */

}
